<%--
    Document   : ViewGameStatistics
    Created on : Dec 21, 2009, 1:02:40 PM
    Author     : 50920709
--%>

<%@page contentType="text/html;charset=UTF-8"%>

<%@ page import="java.util.*" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
	<title>Web Baesd Intelligent Tutoring System in Sudoku for Logic Training</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <%-- CSS is get from http://www.freelayouts.com/ --%>
    <link rel="stylesheet" type="text/css" href="css/default.css" title="default"/>
    <script src="js/ajax.js"></script>
</head>

<body>
    <jsp:include page='header.jsp'/>
    <%@ include file='DatabaseSetup.jsp'%>
    <% String loginFormURL =
               "http://144.214.121.25:8080/SudokuITSWebsite/login.jsp";
    String user = (String) session.getAttribute("user");

    if(user == null) {
        response.setHeader("Refresh", "3; URL=" + loginFormURL);
        out.println(
            "<div class=\"article_body\">" +
            "<p><h2>" +
            "You have not login and will be redirected to the login page after 3 seconds.if not, press <a href=\"login.jsp\">here</a><br/>" +
            "您還沒登入！3秒後進入登入頁面.如沒有，請按<a href=\"login.jsp\">此</a><br/>" +
            "</h2></p>" +
            "</div>");
    }else{

    %>

    <div class="article_head">
        <div class="arrow"></div>
        <h1>I want to check my Sudoku performance with ID

            <select id="pid" onchange="showGameStatic(<%=user%>)">
            <%
                StringBuffer sql = new StringBuffer();
                ResultSet rs = null;
                /* find the number of game finished */
                sql.append("SELECT COUNT(distinct puzzleID) FROM gameskillsmatrix WHERE userID = ");
                sql.append(user);
                rs = stmt.executeQuery(sql.toString());
                int rowCount = 0;
                while(rs.next()){
                    rowCount = Integer.parseInt(rs.getString(1));
                }
                /* display all the game ID in the drop down box*/
                sql = new StringBuffer();
                sql.append("SELECT DISTINCT puzzleID FROM gameskillsmatrix where userID = ");
                sql.append(user);
                sql.append(" ORDER BY puzzleID ASC ");
                rs = stmt.executeQuery(sql.toString());
                out.print("<option value=\"0\"></option>");
                while(rs.next()){
                    out.print("<option value=\"");
                    out.print(rs.getString("PuzzleID"));
                    out.print("\">");
                    out.print(rs.getString("PuzzleID"));
                    out.print("</option>");
                }
                
                rs.close();
                con.close();
                stmt.close();
            %>
            </select>
        </h1>
    </div>

    <div class="article_body">
        <p id="result"></p>
    </div>

    <%
        }
    %>
    <jsp:include page='footer.jsp'/>
</body>